import API from "@/utils/request";

export function getPageOrder({pageNum,pageSize,goodsName,createUserId}){
    return API.get('/order/page',{
        params:{
            pageNum,
            pageSize,
            goodsName,
            createUserId
        }
    })
}

export function getAllOrder(){
    return API.get('/order')
}

export function getOrderById(id){
    return API.get(`/order/${id}`)
}

export function saveOrder(order){
    return API.post('/order',order)
}

export function updateOrder(order){
    return API.put('/order',order)
}

export function removeOrder(id){
    return API.delete(`/order/${id}`)
}

//前台用户获取订单，state为订单状态
export function getPageOrderFront({pageNum,pageSize,state}){
    return API.get('/order/page/front',{
        pageNum,
        pageSize,
        state
    })
}

//根据订单id付款
export function payByOrderId(id){
    return API.put(`/order/pay/${id}`)
}

//支付之前的页面,将购物车的数据发送给后端 data:{carts: JSON.stringify(this.carts)}
export function sendCartList(data){
    return API.post('/order/pre',data)
}

